<template>
	<base-page class="base-form" title="我的班级" @back="onCancel()">
		<view class="content">
			<view v-for="(item,index) in activityInfo" :key="index">
				<u-card :title="item.className" padding="30" margin="26rpx">
					<view class="content" slot="body">
						<view style="display: flex;justify-content: space-between;">
							<view class="u-body-item-title u-line-2" style="white-space: break-spaces">
								班级：{{ item.classPeriods }}
							</view>
						</view>
						<view style="display: flex;justify-content: space-between;">
							<view class="u-body-item-title u-line-2" style="white-space: break-spaces">
								开班日期：{{ item.createTime }}
							</view>
						</view>
						<view style="display: flex;justify-content: space-between;">
							<view class="u-body-item-title u-line-2" style="white-space: break-spaces">
								开班老师：{{item.teacherInfo.name}}
							</view>
						</view>
						<view style="display: flex;justify-content: space-between;">
							<view class="u-body-item-title u-line-2" style="white-space: break-spaces">
								手机号码：{{item.teacherInfo.phone}}
							</view>
						</view>
						<view style="display: flex;justify-content: space-between;">
							<view v-if="!item.scoreVo.score==0"  class="u-body-item-title u-line-2" style="white-space: break-spaces">
								得分：{{item.scoreVo.score}}
							</view>
							
						</view>
					</view>
						<view slot="foot" style="display: flex;align-items: center;justify-content: flex-end;">
							<button v-if="!item.scoreVo.score==0" class="mini-btn" type="primary" size="mini"
								@click="detailsClick(item)">
								得分详情
							</button>
							<button v-if="item.scoreVo.status==1" class="mini-btn" type="primary" size="mini" style="margin-left: 8px;"
								@click="detailsClickzs(item)">
								学分证明
							</button>
						</view>
				</u-card>
			</view>
		</view>
	</base-page>
</template>

<script>
	import {
		CourseInfoController
	} from "@/api";
	export default {
		data() {
			return {
				list: [{
					name: '全部通知'
				}, {
					name: '已发布'
				}, {
					name: '草稿',
				}],
				activityInfo: [],
				activityInfoAll: [],
				current: 0,
				swiperCurrent: 0,
				isAnnounce: null, //0 保存； 1 保存并发布
				jobDetailsArr: [], //作业详情
			}
		},
		mounted() {
			this.getActiveByTeacherIdFun();
		},
		methods: {
			detailsClick(row) {
				const obj = {
					scoreVo: {
						studentId: row.scoreVo.studentId,
						classId: row.scoreVo.classId
					}
				}
				uni.navigateTo({
					url: "/views/generated/ScoreDetails?obj=" +
						encodeURIComponent(
							JSON.stringify(obj)
						),
				});
			},
			detailsClickzs(row){
				const obj = {
					scoreVo: {
						studentId: row.scoreVo.studentId,
						classId: row.scoreVo.classId
					}
				}
				uni.navigateTo({
					url: "/views/generated/certificateDetails?obj=" +
						encodeURIComponent(
							JSON.stringify(obj)
						),
				});
			},
			addPepole() {
				uni.navigateTo({
					url: "/views/school/addPepoles"
				})
			},
			onCancel() {
				if (this.subPage) {
					this.$emit('close');
				} else {
					uni.navigateBack();
				}
			},
			renderTime(date) {
				var dateee = new Date(date).toJSON();
				return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/,
					'')
			},
			publishActivity(row) {
				let classActivity = {
					id: row.id,
					isAnnounce: 1
				}
				updateInfo(classActivity).then((res) => {
					if (res.code == 200) {
						uni.showToast({
							title: `发布成功`
						})
					}
				}).catch((err) => {
					console.error(err);
				});
			},

			editActivity(row) {
				uni.navigateTo({
					url: '/pages/sendNotice/index?data=' + encodeURIComponent(JSON.stringify(row))
				})
			},
			getActiveByTeacherIdFun() {
				CourseInfoController.classManagement(this).then((res) => {
					console.log(res);
					this.activityInfo = res
				}).catch((err) => {
					console.error(err);
				});
			},
		},
		onLoad: function() {}
	}
</script>

<style scoped>
	.content {
		overflow: auto;
	}

	page {
		height: 100%;
		background-color: #f2f2f2;
	}

	.is-disabled .uni-easyinput__placeholder-class[data-v-abe12412] {
		color: black !important;
		font-size: 14px !important;
	}

	.uni-easyinput>>>uni-textarea,
	.content>>>#unieasyinputA,
	#unieasyinputA {
		background-color: #ffffff !important;
	}

	#unieasyinputA>>>.uni-easyinput__content-textarea {
		margin: 0 !important;
	}

	#unieasyinputA>>>.is-input-border {
		border: none !important;
	}
</style>
<style scoped lang="scss">
	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32 rpx;
		color: #333;
		padding: 20 rpx 10 rpx;
	}

	.u-body-item image {
		width: 120 rpx;
		flex: 0 0 120 rpx;
		height: 120 rpx;
		border-radius: 8 rpx;
		margin-left: 12 rpx;
	}

	.u-line-2,
	.u-line-3,
	.u-line-4,
	.u-line-5 {
		display: unset !important;
	}
</style>